import type { IFieldProps, IConfigProps } from '@/components/sofastui/AdvancedTable/interface'
import type { FormRule } from '@form-create/element-ui'

export const fields: IFieldProps[] = [
  {
    label: '角色名称',
    prop: 'name',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '角色编码',
    prop: 'code',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '角色等级',
    prop: 'level',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '角色描述',
    prop: 'desc',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '创建时间',
    prop: 'createdAt',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
    select: false,
  },
  {
    label: '修改时间',
    prop: 'updatedAt',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
    select: false,
  },
]

export const config: IConfigProps = {
  name: 'powRoleTable',
  rowKey: 'id',
  url: '/api/idt/role',
  selection: true,
  add: true,
  delete: true,
  expand: true,
  showIndex: true,
  import: true,
  export: true,
  search: true,
  advancedSearch: true,
  refresh: true,
  settings: true,
}

export const formRules: FormRule = [
  {
    type: 'input',
    field: 'name',
    title: '角色名称',
    $required: true,
    props: {
      placeholder: '请输入角色名称',
    },
    _fc_id: 'id_Fu1lmc22xd9zaic',
    name: 'ref_F4c0mc22xda0ajc',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 12,
    },
  },
  {
    type: 'input',
    field: 'code',
    title: '角色编码',
    $required: true,
    props: {
      placeholder: '请输入角色编码',
    },
    _fc_id: 'id_Fja7mc22xer3alc',
    name: 'ref_F2ajmc22xer3amc',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 12,
    },
  },
  {
    type: 'inputNumber',
    field: 'level',
    title: '角色等级',
    $required: true,
    _fc_id: 'id_Fw46mc4xjwt6eac',
    name: 'level',
    _fc_drag_tag: 'inputNumber',
    col: {
      span: 12,
    },
    props: {
      controlsPosition: 'right',
    },
    value: 1,
    style: {
      width: '100%',
    },
    display: true,
    hidden: false,
  },
  {
    type: 'cascader',
    field: 'roleIds',
    title: '菜单',
    effect: {
      fetch: {
        action: '/api/idt/menu/tree',
        method: 'GET',
        dataType: 'json',
        headers: {},
        query: {},
        data: {},
        parse: '',
        beforeFetch: '',
        onError: '',
        to: 'props.options',
      },
    },
    $required: false,
    props: {
      _optionType: 3,
      props: {
        multiple: true,
        checkStrictly: false,
        emitPath: false,
        value: 'id',
        label: 'title',
        children: 'children',
        disabled: 'disabled',
      },
      collapseTags: true,
      filterable: true,
      showAllLevels: false,
    },
    _fc_id: 'id_Fjc6mc4x5d2xc8c',
    name: 'roleIds',
    _fc_drag_tag: 'cascader',
    col: {
      span: 12,
    },
    style: {
      width: '100%',
    },
    display: true,
    hidden: false,
  },
  {
    type: 'input',
    field: 'desc',
    title: '角色描述',
    $required: false,
    props: {
      type: 'textarea',
      placeholder: '请输入角色描述',
    },
    _fc_id: 'id_Fwn9mc22xutzaoc',
    name: 'ref_Fw67mc22xutzapc',
    display: true,
    hidden: false,
    _fc_drag_tag: 'textarea',
    col: {
      span: 24,
    },
  },
]
